package com.wzf.pojo.resp;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class ResponseReuslt<T> {

    private Integer code;  //状态码
    private String message;  //返回信息
    private T data;    //返回数据

    private ResponseReuslt(){}

    public static <T> ResponseReuslt<T> ok(){
        ResponseReuslt<T> ResponseReuslt = new ResponseReuslt<>();
        ResponseReuslt.setCode(StatusEnum.OK.getCode());
        ResponseReuslt.setMessage(StatusEnum.OK.getMessage());
        return  ResponseReuslt;
    }


    public static <T> ResponseReuslt<T> ok(T data){
        ResponseReuslt<T> ResponseReuslt = new ResponseReuslt<>();
        ResponseReuslt.setCode(StatusEnum.OK.getCode());
        ResponseReuslt.setMessage(StatusEnum.OK.getMessage());
        ResponseReuslt.setData(data);
        return  ResponseReuslt;
    }

    public static <T> ResponseReuslt<T> error(){
        ResponseReuslt<T> ResponseReuslt = new ResponseReuslt<>();
        ResponseReuslt.setCode(StatusEnum.FAIL.getCode());
        ResponseReuslt.setMessage(StatusEnum.FAIL.getMessage());
        return  ResponseReuslt;
    }

    public static <T> ResponseReuslt<T> builder(){
        ResponseReuslt<T> ResponseReuslt = new ResponseReuslt<>();
        return  ResponseReuslt;
    }

    public ResponseReuslt<T> code(Integer code){
        this.setCode(code);
        return  this;
    }

    public ResponseReuslt<T> message(String message){
        this.setMessage(message);
        return  this;
    }

    public ResponseReuslt<T> data(T data){
        this.setData(data);
        return  this;
    }




}
